package com.liang.pcc.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liang.pcc.domain.AuthUser;
import com.liang.pcc.domain.EvaluationHistory;
import com.liang.pcc.service.AuthUserService;
import com.liang.pcc.service.EvaluationHistoryService;
import com.liang.pcc.mapper.EvaluationHistoryMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 评估历史表Service实现
 */
@Service
@RequiredArgsConstructor
public class EvaluationHistoryServiceImpl extends ServiceImpl<EvaluationHistoryMapper, EvaluationHistory> implements EvaluationHistoryService {

    private final AuthUserService authUserService;

    @Override
    public List<EvaluationHistory> getEvaluationHistory(Long fileId) {
        Long userId = authUserService.getUserIdByAccount(StpUtil.getLoginId().toString());
        return lambdaQuery()
                .eq(fileId != null, EvaluationHistory::getFileId, fileId)
                .eq(EvaluationHistory::getUserId, userId)
                .list();
    }
}




